<?php
require_once 'ini.php';


if( !$_SESSION['admin']['uid'] ){
    require_once 'build/login.html';
}else{
    $data =  $_SESSION;
    if(!$_SESSION['admin']['is_admin'])
    {
        $map['aid'] = $_SESSION['admin']['uid'];
    }

    //查询订单和产品
    $allOrderNum = $register->get("db")->count('order',$map);
    $data['allOrderNum'] = $allOrderNum;

    $product =   $register->get("db")->count('product',$map);
    $data['product'] =   $product;

    $map['add_time[<>]'] =[date("Y-m-d 00:00:00"),date("Y-m-d H:i:s")];

    $dayOrderNum =    $register->get("db")->count('order',$map);
    $data['dayOrderNum'] = $dayOrderNum;
    $arr = dayHost();
    
    $dayProduct =   $register->get("db")->count('product',$map);
    $data['dayProductNum'] = $dayProduct;

    $map['erp_status'] = ['FAIL','CREATE_FAIL'];
    unset($map['add_time[<>]']);
    $failNum   =     $register->get("db")->count('order',$map);
    $data['failNum'] = $failNum;

    echo json_encode($data);
    // $register->get("view")->display('index.twig',$data);
    // require_once 'build/index.html';
}


